package list;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public class ListMethod3 {
	public static void main(String[] args) {
		List<Animal> list=new ArrayList<Animal>();
		list.add(new Animal("panda"));
		list.add(new Animal("dog"));
		list.add(new Animal("tiger"));
		list.add(new Animal("lion"));
		p(list.size());
//		for (Animal animal : list) {
//			p(animal);
//		}
		Iterator<Animal> iter=list.iterator();
		while(iter.hasNext()){
			p(iter.next());
		}
//		for (int i = 0; i <list.size(); i++) {
//			p(list.get(i).name);
//		}
	}
	 static void p(Object o){
	    	System.out.println(o);
	    }
}
class Animal{
	
	@Override
	public String toString() {
		return this.name;
	}
	String name;
	public Animal(String name){
		this.name=name;
	}
}